﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace ERP.Utility
{
   public class PublicStr
    {
        public PublicStr()
        {
            //
            // TODO: 在此处添加构造函数逻辑
            //
        }

        public static string GetStateName(string state)
        {
            string str = "";
            switch (state)
            {
                case "-1":
                    str = "未处理";
                    break;
                case "0":
                    str = "草稿";
                    break;
                case "1":
                    str = "已确认";
                    break;
                case "2":
                    str = "已发货";
                    break;
                case "3":
                    str = "已到款";
                    break;
                case "4":
                    str = "已退货";
                    break;
                case "5":
                    str = "确认退款";
                    break;
                case "6":
                    str = "已到货";
                    break;
                case "7":
                    str = "退货通知";
                    break;
                default:
                    str = "草稿单";
                    break;
            }
            return str;
        }

       

        /// <summary>
        /// 返回产品销售类型
        /// </summary>
        /// <param name="typeid">类型id，1为赠品、0为卖品、2为兑换</param>
        /// <returns></returns>
        public static string GetSaleProductType(string typeid)
        {
            switch (typeid)
            {
                case "0":
                    return "卖品";

                case "1":
                    return "赠品";

                case "2":
                    return "兑换";

                default:
                    return "卖品";

            }
        }

        /// <summary>
        /// 获得用户角色名称
        /// </summary>
        /// <param name="kind"></param>
        /// <returns></returns>
        public static string GetKind(string kind)
        {
            switch (kind)
            {
                case "1":
                    return "销售";
                    break;
                case "2":
                    return "库管";
                    break;
                case "3":
                    return "财务";
                    break;
                case "4":
                    return "物流";
                    break;
                case "5":
                    return "管理员";
                    break;
                case "6":
                    return "策划";
                    break;
                case "7":
                    return "运营";
                    break;
                case "8":
                    return "编辑（life5000）";
                    break;
                case "9":
                    return "广告执行";
                    break;
                case "10":
                    return "广告销售";
                    break;
                default:
                    return "";

            }
        }

        /// <summary> 转半角的函数(DBC case) </summary>
        /// <param name="input">任意字符串</param>
        /// <returns>半角字符串</returns>
        ///<remarks>
        ///全角空格为12288，半角空格为32
        ///其他字符半角(33-126)与全角(65281-65374)的对应关系是：均相差65248
        ///</remarks>
        public static string ToDBC(string input)
        {
            char[] c = input.ToCharArray();
            for (int i = 0; i < c.Length; i++)
            {
                if (c[i] == 12288)
                {
                    c[i] = (char)32;
                    continue;
                }
                if (c[i] > 65280 && c[i] < 65375)
                    c[i] = (char)(c[i] - 65248);
            }
            return new string(c);
        }

        /// <summary>
        /// 转全角的函数(SBC case)
        /// </summary>
        /// <param name="input">任意字符串</param>
        /// <returns>全角字符串</returns>
        ///<remarks>
        ///全角空格为12288，半角空格为32
        ///其他字符半角(33-126)与全角(65281-65374)的对应关系是：均相差65248
        ///</remarks>
        public static string ToSBC(string input)
        {
            //半角转全角：
            char[] c = input.ToCharArray();
            for (int i = 0; i < c.Length; i++)
            {
                if (c[i] == 32)
                {
                    c[i] = (char)12288;
                    continue;
                }
                if (c[i] < 127)
                    c[i] = (char)(c[i] + 65248);
            }
            return new string(c);
        }
    }
}
